﻿using RuoVea.ExApp;
using RuoVea.ExDto;

/// <summary>
/// 当前登录用户
/// </summary>
public class UserManager
{
    /// <summary>
    /// 用户
    /// </summary>
    public static long UserId
    {
        get => long.Parse(App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value);
    }
    /// <summary>
    /// 租户
    /// </summary>
    public static long TenantId
    {
        get
        {
            var tId = App.User?.FindFirst(ClaimConst.TENANT_ID)?.Value;
            return string.IsNullOrWhiteSpace(tId) ? 0 : long.Parse(tId);
        }
    }
    /// <summary>
    /// 账号
    /// </summary>
    public static string Account
    {
        get => App.User?.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value;
    }

    /// <summary>
    /// 
    /// </summary>
    public static string RealName
    {
        get => App.User?.FindFirst(ClaimConst.RealName)?.Value;
    }

    /// <summary>
    /// 超管
    /// </summary>
    public static bool SuperAdmin
    {
        get => App.User?.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == RuoVea.ExEnum.AdminType.SuperAdmin.ToString();
    }
    /// <summary>
    /// 机构
    /// </summary>
    public static long OrgId
    {
        get => long.Parse(App.User?.FindFirst(ClaimConst.OrgId)?.Value);
    }
    /// <summary>
    /// 
    /// </summary>
    public static string OpenId
    {
        get => App.User?.FindFirst(ClaimConst.OpenId)?.Value;
    }

}

